﻿/*
 * 
 *   订单信息
 *    浇筑时间  年月日 至 年月日
 *    产品编号
 *    泵送数量   立方米 或 吨  
 *    泵送次数
 *    金额
 *    备注信息：  RemarkParameter1方以内泵车使用费RemarkParameter2元  RemarkParameter3方以上泵车使用费每方泵费加收RemarkParameter4元。如需对方第二次移动泵车每次收费RemarkParameter5元，超出RemarkParameter6公里以外混泥土运输，每公里RemarkParameter7元方。
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

using MaxStudio.Concrete.DBUtility; 

namespace MaxStudio.Concrete.Server.Dao
{
    public partial class ConcreteDaoDataContext : System.Data.Linq.DataContext
    {
        #region PumperDao

        public List<tb_Pumper> GetAllPumper()
        {  
            var query = (from obj in this.tb_Pumpers
                         where obj.IsDelete == 0
                         select obj).ToList();
            return query;
        }

        public tb_Pumper GetPumperById(int id)
        {
            return this.tb_Pumpers.SingleOrDefault(tb_Pumpers => tb_Pumpers.Id == id);
        }

        public List<tb_Pumper> GetPumperBySalesOrderId(int salesOrderId)
        {
            var query = (from obj in this.tb_Pumpers
                         where obj.IsDelete == 0 && obj.SalesOrderId==salesOrderId
                         select obj).ToList();
            return query;
        }

        public void CreatePumper(tb_Pumper entity)
        {
            entity.CreateDate = DateTime.Now;
            entity.CreateBy = 1;
            entity.ModifyDate = DateTime.Now;
            entity.ModifyBy = 1;
            tb_Pumpers.InsertOnSubmit(entity);
            this.SubmitChanges();

        }

        public void ModifyPumper(tb_Pumper entity)
        {
            tb_Pumper instance = this.tb_Pumpers.SingleOrDefault(p => p.Id == entity.Id);
            instance.Id = entity.Id;
            instance.SalesOrderId = entity.SalesOrderId;
            instance.StartDate = entity.StartDate;
            instance.EndDate = entity.EndDate;
            instance.ProductId = entity.ProductId;
            instance.PumpCount = entity.PumpCount;
            instance.PumpCountType = entity.PumpCountType;
            instance.PumpRound = entity.PumpRound;
            instance.Amount = entity.Amount;
            instance.StatusId = entity.StatusId;
            instance.RemarkParameter1 = entity.RemarkParameter1;
            instance.RemarkParameter2 = entity.RemarkParameter2;
            instance.RemarkParameter3 = entity.RemarkParameter3;
            instance.RemarkParameter4 = entity.RemarkParameter4;
            instance.RemarkParameter5 = entity.RemarkParameter5;
            instance.RemarkParameter6 = entity.RemarkParameter6;
            instance.RemarkParameter7 = entity.RemarkParameter7;
            instance.CreateDate = entity.CreateDate;
            instance.CreateBy = entity.CreateBy;  
            instance.IsDelete = entity.IsDelete;
            instance.ModifyBy = 1; //Need to get current user
            instance.ModifyDate = DateTime.Now;

            this.SubmitChanges();
        }
        public void DeletePumper(tb_Pumper entity)
        {
            tb_Pumper deleteEntity = tb_Pumpers.SingleOrDefault(p => p.Id == entity.Id);
            tb_Pumpers.DeleteOnSubmit(deleteEntity);

            this.SubmitChanges();
        }

        #endregion

    }
}
